package com.sun.showcase.controller.app.mall;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sun.showcase.biz.mall.service.AdvertService;
import com.sun.showcase.client.query.mall.AdvertQuery;
import com.sun.showcase.pojo.Result;
@CrossOrigin
@Controller("appAdvertController")
@RequestMapping(value="/app/advert") 
public class AdvertController{
	
	@Autowired
	private AdvertService advertService;
	
	private Result result = new Result();

	/**
	 * 全部数据Advert
	 */
	@ResponseBody
	@RequestMapping(value="homeAdvert")
	public Result listAll() {
		Map<String,Object> res = new HashMap<String,Object>();
		AdvertQuery advertQuery = new AdvertQuery();
		advertQuery.setOrderColum("order_num");
		advertQuery.setOrderRule("ASC");
		advertQuery.setLocation("1");//二号位置
		advertQuery.setStatus("1");
		advertQuery.setActiveTime("1");
		List<AdvertQuery> list = advertService.listAll(advertQuery);
		res.put("adTwo", list);
		advertQuery.setLocation("2");//三号位置
		List<AdvertQuery> list2 = advertService.listAll(advertQuery);
		res.put("adThree", list2);
		result.setSuccess(true);
		result.setMsg("成功！");
		result.setData(res);
		return result;
	}
}
